package com.example.mymvp_2.Retrofit;

import java.io.IOException;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;

import okhttp3.ResponseBody;
import retrofit2.Converter;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import retrofit2.converter.simplexml.SimpleXmlConverterFactory;

public class ServiceImpl {
    public static Retrofit getRetrofit(){
        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl("https://api.66mz8.com")
                .addConverterFactory(GsonConverterFactory.create())
                .build();
        return retrofit;
    }
    public static Retrofit PostRetrofit(){
        Retrofit retrofit=new Retrofit.Builder()
                .baseUrl("http://v.juhe.cn")
                .addConverterFactory(new Converter.Factory() {
                    @Override
                    public Converter<ResponseBody, ?> responseBodyConverter(Type type, Annotation[] annotations, Retrofit retrofit) {
                        return new Converter<ResponseBody, String>() {
                            @Override
                            public String convert(ResponseBody value) throws IOException {
                                return value.string();
                            }
                        };
                    }
                })
                .build();
        return retrofit;
    }
    public static Retrofit XMLRetrofit(){
        Retrofit retrofit=new Retrofit.Builder()
                .baseUrl("https://www.uso.cn")
                .addConverterFactory(SimpleXmlConverterFactory.create())
                .build();
        return retrofit;
    }
}
